package com.yunti.springboot.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yunti.springboot.po.Role;
import com.yunti.springboot.vo.req.RoleReq;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

/**
 * <p>
 * 用户角色关联表 Mapper 接口
 * </p>
 *
 * @author kmustleng
 * @since 2022-12-09
 */
public interface RoleMapper extends BaseMapper<Role> {
    @Select("select id as value ,description as label from role")
    List<Map<String, String>> getRuleList();

    List getSchoolListPage(RoleReq req, Page page);

    @Select("    SELECT r.id as value ,r.description as label" +
            "    FROM user u left join user_role ur on u.id = ur.user_id " +
            "    left join role r on ur.role_id = r.id where u.id = #{id}")

    List<Map<String, String>> getOwnRuleList(Integer id);
}
